package com.hy;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * author: Mr.Du
 * Date: 2023/6/25
 * Time: 14:14
 */
public class CountBeautifulPairs {


    public static void main(String[] args) {
        int[] nums = {31,25,72,79,74};
        int res = countBeautifulPairs(nums);
        System.out.println(res);
    }

    public static int countBeautifulPairs(int[] nums) {
        int res = 0;
        for(int i = 0;i < nums.length;i++){
            for(int j = i + 1;j < nums.length;j++){
                if(isGcd(nums[i],nums[j])) res++;
            }
        }
        return res;
    }

    public static boolean isGcd(int a, int b){
        a = Integer.valueOf(new String(a+"").charAt(0) - '0');
        b = b % 10;
        if (a == 1 || b == 1) {
            return true;
        }
        if (a % b != 0 && b % a != 0) {
            return true;
        }
        return false;

    }
}
